<!--
 * @Author: your name
 * @Date: 2017-08-04 15:54:18
 * @LastEditTime: 2019-12-13 17:43:01
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /courseware_echarts/02/bar.html
 -->
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>bar</title>
    <!-- 引入 echarts.js -->
    <script src="../echarts.min.js"></script>
    <script src="../macarons.js"></script>
</head>

<body>
    <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
    <div id="main" style="width: 900px;height:600px;"></div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'), 'macarons');

        // 指定图表的配置项和数据
        var option = {

            title: {
                text: "",
                subtext: ""
            },
            tooltip: {
                trigger: "axis"
            },
            legend: {
                data: ["风险总数", "检查风险数"]
            },
            toolbox: {
                show: false,
                feature: {
                    mark: {
                        show: true
                    },
                    dataView: {
                        show: true,
                        readOnly: true
                    },
                    magicType: {
                        show: false,
                        type: ["line", "bar"]
                    },
                    restore: {
                        show: true
                    },
                    saveAsImage: {
                        show: true
                    }
                }
            },
            calculable: true,
            xAxis: [{
                type: "category",
                data: ["32", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"],
                splitLine: {
                    show: false
                },
                axisLabel: {
                    textStyle: {
                        color: "rgb(109, 114, 120)"
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: "rgb(214, 214, 214)",
                        width: 1
                    }
                }
            }],
            yAxis: [{
                type: "value",
                name: "风险（单位：个）",
                nameLocation: "end",
                nameTextStyle: {
                    color: "rgb(109, 114, 120)"
                },
                splitLine: {
                    show: false
                },
                splitArea: {
                    show: true
                },
                axisLabel: {
                    textStyle: {
                        color: "rgb(109, 114, 120)"
                    }
                },
                axisLine: {
                    lineStyle: {
                        color: "rgb(214, 214, 214)",
                        width: 1
                    }
                }
            }],
            series: [{
                    name: "风险总数",
                    type: "bar",
                    data: [2, 4.9, 7, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20, 6.4, 3.3]
                },
                {
                    name: "检查风险数",
                    type: "bar",
                    data: [2.6, 5.9, 9, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6, 2.3]
                }
            ],
            color: ["rgb(6, 152, 105)", "rgb(255, 126, 34)"]
        }

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>

</html>